package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


//攻略分类

@Setter@Getter
//有代理对象时,因为懒加载的缘故会出现问题  要禁止序列化handler属性    还可以加其他不进行序列化的属性
@JsonIgnoreProperties("handler")
public class StrategyCatalog {


    private Long id;
    //分类名称
    private String name;
    //所属攻略
    private Strategy strategy;
    //序号
    private Integer sequence;
    //状态
    private boolean state;
    //文章集合
    private List<StrategyDetail> details = new ArrayList<StrategyDetail>();

    public String getJsonString(){
        HashMap<Object,Object> map = new HashMap();
        map.put("id",id);
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        if(strategy!=null){
            map.put("strategyId",strategy.getId());
        }
        return JSON.toJSONString(map);
    }

}